package com.meizu.asum.richtextsdk.uiframework.xuidesign.utils;

import android.content.Context;
import android.content.Intent;

import com.meizu.asum.richtextsdk.tools.ScreenSizeTools;
import com.meizu.asum.richtextsdk.uiframework.xlayoutparam.utils.StateHeight;
import com.meizu.asum.richtextsdk.uiframework.xuidesign.interfaces.IUIDesigner;
import com.meizu.asum.richtextsdk.uiframework.xuidesign.utils.view.ImmersionTools;
import com.meizu.asum.richtextsdk.uiframework.xuidesign.utils.view.TextViewTools;

/**
 * Layout设计者基类
 *
 * @Author XJW
 * @CreateTime 2017/9/8
 */
public abstract class BaseLayoutDesigner implements IUIDesigner {
    public Context context;
    public XDesigner designer;
    public int screenW, screenH;
    public int stateHeight;
    public int padding;
    public int space;
    public double x, y, w, h;
    public TextViewTools tTools;

    public final void design(XDesigner designer, Intent intent) {
    }

    public final void design(XDesigner designer, Object... values) {
        this.designer = designer;
        context = designer.getContext();
        screenW = ScreenSizeTools.getW(context);
        screenH = ScreenSizeTools.getH(context);
        stateHeight = StateHeight.getStatusHeight(context);

        if (!ImmersionTools.canImmersion()) {
            stateHeight = 0;
        }

        try {
            if (values.length >= 4) {
                x = (double) values[0];
                y = (double) values[1];
                w = (double) values[2];
                h = (double) values[3];
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        tTools = new TextViewTools();

        design(values);
        getWidgets();
        setWidgets();
    }

    public void design(Object... values) {
    }

    protected abstract void getWidgets();

    protected abstract void setWidgets();
}
